package api_day09;

import org.junit.Test;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class IOStreamDemo {
    @Test //写入文件
    public void test01() throws IOException {
        FileOutputStream output = new FileOutputStream("src/api_day09/out.txt");
/*        output.write(77);
        output.write(88);
        output.write(55);
        output.write(-1);
        output.write(33);
        output.write(76);
        output.write(25);
        output.write(45);
        output.write(256);*/
        output.write("hellow stream".getBytes());
        output.write("hellow stream".getBytes(),2,6);
//        System.out.println(output);
    }
    @Test //读取文件
    public void test02() throws IOException {
        FileInputStream input = new FileInputStream("src/api_day09/out.txt");
/*        while (true){
            int read = input.read();
            if (read == -1) break;
            System.out.println(read);
        }*/
//        int read1 = input.read("hellow stream".getBytes());
//        System.out.println(read1);
//        int read2 = input.read("hellow stream".getBytes(), 2, 6);
//        System.out.println(read2);
    }
}
